home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 13 - 1997 (partial) / 13.03 Mar 97 / Leigh.OberonF / MactechHelloWorld.Source (.txt) next >
Encoding:
Oberon Document  |  1996-09-29  |  3.2 KB  |  97 lines  |  [BINA/hDmp]

  1. Documents.StdDocumentDesc
  2. Documents.DocumentDesc
  3. Containers.ViewDesc
  4. Views.ViewDesc
  5. Stores.StoreDesc
  6. Documents.ModelDesc
  7. Containers.ModelDesc
  8. Models.ModelDesc
  9. Stores.ElemDesc
  10. TextViews.StdViewDesc
  11. TextViews.ViewDesc
  12. TextModels.StdModelDesc
  13. TextModels.ModelDesc
  14. TextModels.AttributesDesc
  15. Helvetica
  16. (*  This module deomstrates a simple "HelloWorld" program using the Mac toolbox calls with Oberon.  This is a complete module by itself and can be compiled and run
  17. as is. *)
  18. MODULE MactechHelloWorld;  
  19. IMPORT
  20.        SYSTEM,
  21.             RM := MacResourceMgr,
  22.             QD := MacQuickDraw, FS := MacFileMgr, 
  23.             MacFontMgr,  MacWindowMgr,
  24.             MN := MacMenuMgr, TE := MacTextEdit, DL := MacDialogMgr, 
  25.             MT := MacTypes,
  26.             EV := MacEventMgr, ME := MacMemoryMgr, OS := MacOSUtils;
  27.        gWindowRect :  QD.Rect;
  28.        gWindowRefCon :  LONGINT;
  29.        gWindow :  MacWindowMgr.WindowPtr;
  30. (* InitMac initializes the Mac ToolBox *)
  31. PROCEDURE InitMac;
  32. BEGIN
  33.     QD.InitGraf(QD.globals.thePort);
  34.     (* The QuickDraw Globals are Oberon Variables *)
  35.     MacFontMgr.InitFonts;
  36.     MacWindowMgr.InitWindows;
  37.     MN.InitMenus;
  38.     TE.TEInit;
  39.     DL.InitDialogs(0);
  40.     QD.InitCursor;
  41. END InitMac;
  42. (* Create a new window and display it *)
  43. PROCEDURE MakeWindow;
  44.   windowTitle : MT.Str255;
  45.   temp : ARRAY 256 OF CHAR;
  46.   behind : MacWindowMgr.WindowPtr;  
  47.         (* behind flag in NewWindow *)
  48. BEGIN
  49.   temp := "MacTech Magazine";
  50.   behind := SYSTEM.VAL(MacWindowMgr.WindowPtr, -1);
  51.   MT.SetStr255(windowTitle, temp);
  52.   QD.SetRect(gWindowRect, 50, 200, 300, 400);
  53.   gWindow :=  MacWindowMgr.NewWindow(NIL, gWindowRect,                                                     windowTitle, TRUE, MacWindowMgr.noGrowDocProc, 
  54.                                                 behind, TRUE, gWindowRefCon);
  55.                                     
  56.     MacWindowMgr.ShowWindow(gWindow);
  57. END MakeWindow;
  58. (* Draw our "HelloWorld" string in the window *)
  59. PROCEDURE HelloWorld;
  60.   oldPort : QD.GrafPtr;
  61.   helloWorld : MT.Str255;
  62.   temp : ARRAY 256 OF CHAR;
  63. BEGIN
  64.   temp := "Hello World";
  65.   MT.SetStr255(helloWorld, temp);
  66.   QD.GetPort(oldPort);
  67.   QD.SetPort(gWindow);
  68.   QD.TextSize(26);
  69.   QD.MoveTo(25, 100);
  70.   QD.DrawString(helloWorld);
  71.   QD.SetPort(oldPort);
  72.   END HelloWorld;
  73. (* Create our Do command.  Can be run inside the Oberon environment. *)
  74. PROCEDURE Do*;
  75. BEGIN
  76.   InitMac;
  77.   MakeWindow;
  78.   HelloWorld;
  79.   REPEAT
  80.       UNTIL EV.Button();
  81.   MacWindowMgr.DisposeWindow(gWindow);
  82.   END Do;
  83. (* Main program begin.  If we are to compile and link this as a separate application then this section should make a single call to Do; *)
  84. BEGIN
  85.   END MactechHelloWorld.
  86. TextControllers.StdCtrlDesc
  87. TextControllers.ControllerDesc
  88. Containers.ControllerDesc
  89. Controllers.ControllerDesc
  90. TextRulers.StdRulerDesc
  91. TextRulers.RulerDesc
  92. TextRulers.StdStyleDesc
  93. TextRulers.StyleDesc
  94. TextRulers.AttributesDesc
  95. Helvetica
  96. Documents.ControllerDesc
  97.